/**
 * 用于websocket连接
 */
let websocket = null;
if ('WebSocket' in window) {
	websocket = new WebSocket('ws://localhost:8082/socket/asset');
}
else {
	alert("浏览器不支持");
}
websocket.onopen = function(event) {
	console.log('建立连接');
	websocket.send("消息发送测试（客户端）");
}
websocket.onclose = function(event) {
	console.log('连接关闭');
}
websocket.onmessage = function(event) {
	console.log('收到消息::' + event.data);
	//在此写收到消息后的操作
}
websocket.onerror = function() {
	console.log('error');
}
window.onbeforeunload = function() {
	websocket.close();
}